package com.aios.action.settings.controller;

import org.apache.log4j.Logger;

public class ControllerDeleteAction extends AbstractControllerAction {
	
	private static final long serialVersionUID = 1L;
	private static Logger logger = Logger.getLogger(ControllerDeleteAction.class);
	
	public String execute() {
		
		if(id != null) {
			
			try {
				controllerService.delete(id);
			} catch(Exception e) {
				logger.error(e);
				addActionError(getText("global.error.delete"));
				return ERROR;
			}
			
		} else {
			logger.error("Trying to delete a controller without passing its id");
			addActionError(getText("global.error.delete"));
			return ERROR;
		}
		
		addActionError(getText("global.success.delete"));
		
		return SUCCESS;
	}
	
}
